//
//  LiverMsgVC.m
//  Bread-Live
//
//  Created by ios on 2017/3/13.
//  Copyright © 2017年 Chris. All rights reserved.
//

#import "LiverMsgVC.h"
#import "LiverHeadView.h"
#import "HotLiverModel.h"
#import "TitleView.h"
#import "LiveThemeTableViewCell.h"

static NSString *listCell = @"Cell";

@interface LiverMsgVC ()<UITableViewDelegate,UITableViewDataSource>
@property(nonatomic,strong) UITableView   *wTableView;
@property(nonatomic,strong) LiverHeadView *headerView;

@end

@implementation LiverMsgVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    NSDictionary *dic = @{
                          @"isfollow":@YES,
                          @"name":@"陈大可",
                          @"headImgUrl":@"http://images.mianbaolive.com/manage/895d4d9e-cb67-4c55-b4af-8ab29112fa2a.jpg",
                          @"time":@"8天前·直播·END",
                          @"descritionText":@"本话题适用于：刚开始找工作的大学毕业生，工作超过四年但是缺乏跳槽经验的职场人士，职场经验丰富但是简历缺乏亮点的职场人士。课程中间有有奖问答，欢迎来听。",
                          @"title":@"打造优质简历，帮你敲开企业大门",
                          @"bgUrl":@"http://images.mianbaolive.com/manage/895d4d9e-cb67-4c55-b4af-8ab29112fa2a.jpg",
                          @"fansNumber":@"100"
                          
                          };
    HotLiverModel *model = [[HotLiverModel alloc] init];
    
    [model setValuesForKeysWithDictionary:dic];
    
    self.headerView.model = model;
    
    NSString *text = model.descritionText;
    
    CGFloat height1 = [ToolsCustom getSpaceLabelHeight:text withFont:[UIFont wyNormalFot:14] withWidth:kWidth-40 lineSpacing:5];
    
    self.headerView.frame = CGRectMake(0, 0, kWidth, 200+height1);
    
    [self.headerView setDescritionText:text];
    
    
    [self.wTableView reloadData];
    
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 2;
    
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 5.0;
}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    
    return [TitleView initWithTitle:@"XX 的直播"];
    
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 100;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 40;
}



-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    LiveThemeTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:listCell];
    
    
    return cell;
}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}


-(UITableView *)wTableView{
    if (!_wTableView) {
        _wTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0,kWidth,kHeight) style:UITableViewStyleGrouped];
        _wTableView.delegate = self;
        _wTableView.dataSource = self;
        _wTableView.tableHeaderView = self.headerView;
        
        [_wTableView registerClass:[LiveThemeTableViewCell class] forCellReuseIdentifier:listCell];
        
        [self.view addSubview:_wTableView];
        
        
    }
    return _wTableView;
}

-(LiverHeadView *)headerView{
    
    if (!_headerView) {
        _headerView = [[ LiverHeadView alloc] initWithFrame:CGRectMake(0, 0, kWidth, 200)];
        
    }
    return _headerView;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
